package com.zhouheng.springbootconverter.util;

import lombok.extern.log4j.Log4j2;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * 时间工具类
 *
 * @author 周恒
 * @date 20200421 16:27:49
 * @since v1.0
 */
@Log4j2
public class LocalDateTimeUtils {

    private LocalDateTimeUtils() {
    }

    public static final String DATE_TIME_ZERO = " 00:00:00";
    public static final String DATE_TIME_0 = "000000";
    public static final String DATE_TIME_01 = "yyyy-MM-dd";
    public static final String DATE_TIME_03 = "yyyyMMddHHmmss";
    public static final String DATE_TIME_02 = "yyyyMMdd";
    public static final String DATE_TIME_04 = "yyyy-MM-dd HH:mm:ss";
    public static final String DATE_TIME_05 = "yyyyMM";
    public static final String DATE_TIME_06 = "MMdd";
    public static final String DATE_TIME_07 = "MM-dd";
    public static final String DATE_TIME_08 = "HH:mm:ss";

    /**
     * String转localDateTime
     *
     * @return 返回 local date time 描述此返回参数
     * @author 周恒
     * @date 20181122 10:39:01
     * @since v1.0
     */
    public static LocalDateTime stringToLocalDateTime(String timeStr, String dtfStr) {
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(dtfStr);
        return LocalDateTime.parse(timeStr, dateTimeFormatter);
    }

}
